﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/MasterPage.master" AutoEventWireup="true" CodeFile="ThemLoaiSanPham.aspx.cs" Inherits="Admin_ThemLoaiSanPham" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">


<h3>Thêm loại sản phẩm</h3>


    <asp:ListView ID="ListView1" runat="server" DataKeyNames="IDLoaiTL" OnItemInserting="lvCountries_ItemInserting"
        DataSourceID="SqlDataSource1" EnableModelValidation="True" 
        InsertItemPosition="LastItem">
        <InsertItemTemplate>
        <table class="table_them_loai_sp">
          <tr>
            <td class="ten_loai_sp">Tên loại (tiếng Việt):</td>
            <td class="ten_loai_sp"><asp:TextBox ID="TenLoaiTLTextBox" runat="server" 
                Text='<%# Bind("TenLoaiTL") %>' /></td>
                </tr> 
                <tr>
            <td>Tên loại (tiếng Anh):</td>
            <td><asp:TextBox ID="TenLoaiTL_enTextBox" runat="server" 
                Text='<%# Bind("TenLoaiTL_en") %>' /></td>
                </tr>
                 <tr>
            <td>Thuộc về:</td>
          <td>
           <asp:DropDownList ID="ddlLoaiTLCha" runat="server" AppendDataBoundItems="true"
               DataSourceID="SqlDataSource2"
               DataTextField="TenLoaiTL"
               DataValueField="IDLoaiTL"
            >
            <asp:ListItem Value="0" Text="--Không có--"></asp:ListItem>
            </asp:DropDownList></td>
            </tr>

            <tr>
            <td>Thứ tự hiển thị:</td>
            <td>
            <asp:TextBox ID="ThuTuHienThiTextBox" runat="server" 
                Text='<%# Bind("ThuTuHienThi") %>' /></td>
              </tr>
              <tr>
            <td>Loại Copy:</td>
         
            <td>
            <asp:DropDownList ID="ddlLoaiCopy" runat="server">
            <asp:ListItem Value="1" Text="Hard-Copy"></asp:ListItem>
            <asp:ListItem Value="0" Text="Soft-Copy"></asp:ListItem>
            </asp:DropDownList>  </td>
            </tr>        
            <tr>
            <td colspan="2" class="td_them_sp" align="center">
  
            
            <asp:Button ID="InsertButton2" runat="server" CommandName="Insert" CssClass="button"
                Text="Thêm" />
            <asp:Button ID="InsertButton" runat="server" CommandName="Insert" OnClick="To_DanhSach" CssClass="button"
                Text="Về danh sách" />
            <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" CssClass="button"
                Text="Nhập lại" />

                </td>
                </tr>
            </table>
        </InsertItemTemplate>

        <LayoutTemplate>
            <div ID="itemPlaceholderContainer" runat="server" 
                style="font-family: Verdana, Arial, Helvetica, sans-serif;">
                <span runat="server" id="itemPlaceholder" />
            </div>
            <div style="text-align: center;background-color: #5D7B9D;font-family: Verdana, Arial, Helvetica, sans-serif;color: #FFFFFF;">
            </div>
        </LayoutTemplate>
        <SelectedItemTemplate>
            <span style="background-color: #E2DED6;font-weight: bold;color: #333333;">
            IDLoaiTL:
            <asp:Label ID="IDLoaiTLLabel" runat="server" Text='<%# Eval("IDLoaiTL") %>' />
            <br />
            TenLoaiTL:
            <asp:Label ID="TenLoaiTLLabel" runat="server" Text='<%# Eval("TenLoaiTL") %>' />
            <br />
            TenLoaiTL_en:
            <asp:Label ID="TenLoaiTL_enLabel" runat="server" 
                Text='<%# Eval("TenLoaiTL_en") %>' />
            <br />
            IDLoaiTLCha:
            <asp:Label ID="IDLoaiTLChaLabel" runat="server" 
                Text='<%# Eval("IDLoaiTLCha") %>' />
            <br />
            ThuTuHienThi:
            <asp:Label ID="ThuTuHienThiLabel" runat="server" 
                Text='<%# Eval("ThuTuHienThi") %>' />
            <br />
            LoaiCopy:
            <asp:Label ID="LoaiCopyLabel" runat="server" Text='<%# Eval("LoaiCopy") %>' />
            <br />
<br /></span>
        </SelectedItemTemplate>
    </asp:ListView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConflictDetection="CompareAllValues" 
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
        DeleteCommand="DELETE FROM [LoaiTaiLieu] WHERE [IDLoaiTL] = @original_IDLoaiTL AND (([TenLoaiTL] = @original_TenLoaiTL) OR ([TenLoaiTL] IS NULL AND @original_TenLoaiTL IS NULL)) AND (([TenLoaiTL_en] = @original_TenLoaiTL_en) OR ([TenLoaiTL_en] IS NULL AND @original_TenLoaiTL_en IS NULL)) AND (([IDLoaiTLCha] = @original_IDLoaiTLCha) OR ([IDLoaiTLCha] IS NULL AND @original_IDLoaiTLCha IS NULL)) AND (([ThuTuHienThi] = @original_ThuTuHienThi) OR ([ThuTuHienThi] IS NULL AND @original_ThuTuHienThi IS NULL)) AND (([LoaiCopy] = @original_LoaiCopy) OR ([LoaiCopy] IS NULL AND @original_LoaiCopy IS NULL))" 
        InsertCommand="INSERT INTO [LoaiTaiLieu] ([TenLoaiTL], [TenLoaiTL_en], [IDLoaiTLCha], [ThuTuHienThi], [LoaiCopy]) VALUES (@TenLoaiTL, @TenLoaiTL_en, @IDLoaiTLCha, @ThuTuHienThi, @LoaiCopy)" 
        OldValuesParameterFormatString="original_{0}" 
       
        UpdateCommand="UPDATE [LoaiTaiLieu] SET [TenLoaiTL] = @TenLoaiTL, [TenLoaiTL_en] = @TenLoaiTL_en, [IDLoaiTLCha] = @IDLoaiTLCha, [ThuTuHienThi] = @ThuTuHienThi, [LoaiCopy] = @LoaiCopy WHERE [IDLoaiTL] = @original_IDLoaiTL AND (([TenLoaiTL] = @original_TenLoaiTL) OR ([TenLoaiTL] IS NULL AND @original_TenLoaiTL IS NULL)) AND (([TenLoaiTL_en] = @original_TenLoaiTL_en) OR ([TenLoaiTL_en] IS NULL AND @original_TenLoaiTL_en IS NULL)) AND (([IDLoaiTLCha] = @original_IDLoaiTLCha) OR ([IDLoaiTLCha] IS NULL AND @original_IDLoaiTLCha IS NULL)) AND (([ThuTuHienThi] = @original_ThuTuHienThi) OR ([ThuTuHienThi] IS NULL AND @original_ThuTuHienThi IS NULL)) AND (([LoaiCopy] = @original_LoaiCopy) OR ([LoaiCopy] IS NULL AND @original_LoaiCopy IS NULL))">
        <DeleteParameters>
            <asp:Parameter Name="original_IDLoaiTL" Type="Int32" />
            <asp:Parameter Name="original_TenLoaiTL" Type="String" />
            <asp:Parameter Name="original_TenLoaiTL_en" Type="String" />
            <asp:Parameter Name="original_IDLoaiTLCha" Type="Int32" />
            <asp:Parameter Name="original_ThuTuHienThi" Type="Int32" />
            <asp:Parameter Name="original_LoaiCopy" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="TenLoaiTL" Type="String" />
            <asp:Parameter Name="TenLoaiTL_en" Type="String" />
            <asp:Parameter Name="IDLoaiTLCha" Type="Int32" />
            <asp:Parameter Name="ThuTuHienThi" Type="Int32" />
            <asp:Parameter Name="LoaiCopy" Type="Int32" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="TenLoaiTL" Type="String" />
            <asp:Parameter Name="TenLoaiTL_en" Type="String" />
            <asp:Parameter Name="IDLoaiTLCha" Type="Int32" />
            <asp:Parameter Name="ThuTuHienThi" Type="Int32" />
            <asp:Parameter Name="LoaiCopy" Type="Int32" />
            <asp:Parameter Name="original_IDLoaiTL" Type="Int32" />
            <asp:Parameter Name="original_TenLoaiTL" Type="String" />
            <asp:Parameter Name="original_TenLoaiTL_en" Type="String" />
            <asp:Parameter Name="original_IDLoaiTLCha" Type="Int32" />
            <asp:Parameter Name="original_ThuTuHienThi" Type="Int32" />
            <asp:Parameter Name="original_LoaiCopy" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>

    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
        SelectCommand="SELECT [IDLoaiTL],[TenLoaiTL] FROM [LoaiTaiLieu]"></asp:SqlDataSource>

</asp:Content>

